<template>
    <div>
        <a href="/Adda">新增医生</a>
        <h1>显示医生列表</h1>
        <table class="table">
            <thead>
                <tr>
                    <td>医生编号</td>
                    <td>医生姓名</td>
                    <td>头像</td>
                    <td>科室</td>
                    <td>创建时间</td>
                </tr>
            </thead>
            <tbody>
                <tr v-for="a in date">
                    <td>{{ a.actiorId }}</td>
                    <td>{{ a.actiorName }}</td>
                    <td><img :src="'https://localhost:7261/'+a.img" width="60px" height="60px"></td>
                    <td>{{ a.kHouseId }}</td>
                    <td>{{ moment(a.dates).format("YYYY-MM-DD HH:MM:SS") }}</td>
                </tr>
            </tbody>
        </table>
        <input type="button" value="首页" @click="fanye(1)">
        <input type="button" value="上一页" @click="fanye(2)">
        <input type="button" v-for="c in zys.row" :value="c" @click="yema(c)">
        <input type="button" value="下一页" @click="fanye(3)">
        <input type="button" value="尾页" @click="fanye(4)">
        当前第{{ ts.index }}页 每页{{ zys.row }}条 共{{ ts.size }}页 共{{ zys.list }}条
        <select v-model="ts.size" @click="yerongliang">
            <option>2</option>
            <option>4</option>
            <option>6</option>
        </select>
        <input type="number" v-model="ts.index"><input type="button" value="跳转" @click="tiao()">
        <br>
        <a href="/Addk">科室</a>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import moment from 'moment';
import { ref,onMounted } from 'vue';
import { useRouter } from 'vue-router';
const routher = useRouter()
onMounted(()=>{
    getdate()
    show()
})
const yema=(val:any)=>{
    ts.value.index=val
    show()
}
//页容量
const yerongliang=()=>{
    show()
}
//跳转
const tiao=()=>{
    show()
}
const ts=ref({
    index:1,
    size:2
})
const zys=ref({
    list:0,
    row:0
})
const fanye=(val:any)=>{
    if(val==1){
        ts.value.index=1
        show()
    }
    if(val==2){
        if(ts.value.index>1){
            ts.value.index-=1
            show()
        }
    }
    if(val==3){
        if(ts.value.index<zys.value.row){
            ts.value.index+=1
            show()
        }
    }
    if(val==4){
        ts.value.index=zys.value.row
        show()
    }
}
const show=()=>{
    axios.get("/api/Actior/ShowActior",{params:ts.value}).then(res=>{
        date.value=res.data.row
        zys.value.list=res.data.list
        zys.value.row=Math.ceil(res.data.list/ts.value.size)
    })
}
const date=ref([{
  "actiorId": 0,
  "actiorName": "",
  "img": "",
  "kHouseId": 0,
  "dates": ""
}])
const getdate=()=>{
    axios.get("/api/KHouse/Xia").then(res=>{
        data.value=res.data
    })
}
const data=ref([{
    "kHouseId": 0,
    "kHouseName": ""
}])
</script>

<style scoped>

</style>